home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / INFO / XFDISK.ZIP / BOOTREC2.BAS next >
BASIC Source File  |  1991-08-29  |  8KB  |  164 lines

  1. 1000 ' BOOTREC2.BAS -- Checks Disk Boot Record (BIOS Parameter Block)
  2. 1010 '
  3. 1020 ' ╔═══════════════════════════════════════════════════════════════════════╗
  4. 1030 ' ║ REFERENCE:                                                            ║
  5. 1040 ' ║   PC Magazine DOS Power Tools (techniques, tricks, and utilities),    ║
  6. 1050 ' ║   Paul Somerson, Bantam Computer Books, June 1988                     ║
  7. 1060 ' ║                                                                       ║
  8. 1070 ' ║   BOOTREC.BAS -- Checks Boot Record -- Paul Somerson                  ║
  9. 1080 ' ║   (c) 1987 Ziff Communications Co.                                    ║
  10. 1090 ' ║                                                                       ║
  11. 1100 ' ║ Revised BOOTREC.BAS as follows:                                       ║
  12. 1110 ' ║ .Loop after printing boot record info. to prompt for another drive.   ║
  13. 1120 ' ║  Exit loop by pressing Esc at prompt and return to DOS.               ║
  14. 1130 ' ║ .Allowed any drive letter from A to Z to be specified.                ║
  15. 1140 ' ║ .Added comments to 'Figure things out' section to identify BPB bytes. ║
  16. 1150 ' ║ .Fixed tracks per side calculation to include hidden sectors, so      ║
  17. 1160 ' ║  tps value would be correct for fixed disks.                          ║
  18. 1170 ' ║ .Fixed DS# calculation to include number of reserved (boot) sectors   ║
  19. 1180 ' ║  instead of defaulting to 1.                                          ║
  20. 1190 ' ║ .Added calculation for number of unused sectors.  These sectors are   ║
  21. 1200 ' ║  not used because of the disk allocation unit (cluster) size.         ║
  22. 1210 ' ║ .Changed DEBUG script filename from SCRIPT.FIL to BOOTREC.SCR         ║
  23. 1220 ' ║ .Changed DEBUG  data  filename from    RAW.FIL to BOOTREC.DAT         ║
  24. 1230 ' ║ .Revised media description byte report.                               ║
  25. 1240 ' ║                                                                       ║
  26. 1250 ' ║ Written by:  Dennis W. Person                  Date:  August 29, 1991 ║
  27. 1260 ' ║              6828 Devonshire Drive                                    ║
  28. 1270 ' ║              Canton, Michigan  48187-2613                             ║
  29. 1280 ' ╚═══════════════════════════════════════════════════════════════════════╝
  30. 1290 '
  31. 1300 ' --- Setup ---
  32. 1310 '
  33. 1320 SCREEN 0,0,0,0:COLOR 7,1,7:KEY OFF:CLS:DIM B(30)
  34. 1330 '
  35. 1340 B$=STRING$(35,205)
  36. 1350 F$="5¼ inch,"
  37. 1360 T$="3½ inch,"
  38. 1370 S$="Sectors"
  39. 1380 S1$="Side,"
  40. 1390 S2$="Sides,"
  41. 1400 S3$="Tracks,"
  42. 1410 '
  43. 1420 ' --- Ask which drive to check ---
  44. 1430 '
  45. 1440 LOCATE 25,1:COLOR 15,4:PRINT SPACE$(80);
  46. 1450 LOCATE 25,1:PRINT " Press ";:COLOR 14:PRINT "ESC";:COLOR 15
  47. 1460 PRINT " to exit to DOS.";:COLOR 7,1
  48. 1470 '
  49. 1480 LOCATE 24,1,1,6,7 :'turn cursor on and set scan lines for underscore
  50. 1490 PRINT " Enter letter of drive to be examined (A..Z) ? ";
  51. 1500 J$=INKEY$:IF J$="" THEN 1500 ELSE IF J$=CHR$(27) THEN 2610
  52. 1510 K=CINT(INSTR("AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz",J$)/2)
  53. 1520 IF K=0 THEN 1480 
  54. 1530 Z$=CHR$(K+64)+":":PRINT Z$;
  55. 1540 '
  56. 1550 ' --- Create DEBUG script and read disk boot record ---
  57. 1560 '
  58. 1570 OPEN "BOOTREC.SCR" FOR OUTPUT AS #1
  59. 1580 PRINT #1,"L 100";K-1;"0 1"
  60. 1590 PRINT #1,"D 100 L 20"
  61. 1600 PRINT #1,"Q"
  62. 1610 CLOSE #1
  63. 1620 SHELL "DEBUG < BOOTREC.SCR > BOOTREC.DAT"
  64. 1630 '
  65. 1640 ' --- Read raw bytes into array D$() ---
  66. 1650 '
  67. 1660 OPEN "BOOTREC.DAT" FOR INPUT AS #1:A=0
  68. 1670 WHILE NOT EOF(1)
  69. 1680   LINE INPUT #1,A$
  70. 1690   IF LEFT$(A$,4)<>"Disk" THEN 1710
  71. 1700   BEEP:CLS:PRINT "Invalid disk -- ";Z$:CLOSE:GOTO 2550
  72. 1710   IF LEN(A$)<70 THEN 1730
  73. 1720     D$(A)=MID$(A$,12,48):A=1
  74. 1730 WEND
  75. 1740 IF MID$(D$(0),38,1)="2" THEN 1760
  76. 1750 PRINT "Why are you using DOS 1.x ??  Upgrade!":CLOSE:GOTO 2550
  77. 1760 D$=D$(0)+MID$(D$(1),1,41)
  78. 1770 FOR A=0 TO 29
  79. 1780   B(A+1)=VAL("&H"+MID$(D$,3*A+1,2))
  80. 1790 NEXT
  81. 1800 CLOSE #1
  82. 1810 '
  83. 1820 ' --- Figure things out ---
  84. 1830 '
  85. 1840 BS=B(13)*256+B(12) :'number of bytes per sector
  86. 1850 SC=B(14)           :'number of sectors per cluster
  87. 1860 RS=B(16)*256+B(15) :'number of reserved (boot) sectors
  88. 1870 ' =B(17)           :'number of FAT's
  89. 1880 RD=B(19)*256+B(18) :'maximum number of root directory entries
  90. 1890 TS=B(21)*256+B(20) :'total number of sectors (w/o hidden sectors)
  91. 1900 ' =B(22)           :'media descriptor byte
  92. 1910 SF=B(24)*256+B(23) :'number of sectors per FAT
  93. 1920 ST=B(26)*256+B(25) :'number of sectors per track
  94. 1930 NS=B(28)*256+B(27) :'number of heads (sides)
  95. 1940 HS=B(30)*256+B(29) :'number of hidden sectors
  96. 1950 '
  97. 1960 ' --- Calculate totals ---
  98. 1970 '
  99. 1980 TF=SF*B(17)         :'total number of sectors allocated to FATs
  100. 1990 SD=RD*32/BS         :'total number of sectors allocated to root directory
  101. 2000 SS=TS-SD-TF-RS      :'total number of sectors available to data area
  102. 2010 US=SS-INT(SS/SC)*SC :'total number of unused (not allocated) sectors
  103. 2020 TB#=TS*BS           :'total number of bytes available on disk
  104. 2030 DS#=(SS-US)*BS      :'total number of bytes available on disk for data
  105. 2040 '
  106. 2050 TD=FIX((TS+HS)/NS/ST) :'tracks per side on disk
  107. 2060 '
  108. 2070 ' --- And print report ---
  109. 2080 '
  110. 2090 CLS:PRINT B$;" Drive ";Z$;" ";B$
  111. 2100 PRINT " OEM Name and version:";TAB(38);
  112. 2110 FOR A=4 TO 11:PRINT CHR$(B(A));:NEXT:PRINT
  113. 2120 PRINT " Total sectors:";TAB(37);TS
  114. 2130 PRINT " Bytes per sector:";TAB(37);BS
  115. 2140 PRINT " Sectors per cluster:";TAB(37);SC
  116. 2150 PRINT " Bytes per cluster:";TAB(37);SC*BS
  117. 2160 PRINT " Reserved (boot record) sectors:";TAB(37);RS
  118. 2170 PRINT " Sectors per track:";TAB(37);ST
  119. 2180 PRINT " Number of hidden sectors:";TAB(37);HS
  120. 2190 PRINT " Number of heads (sides):";TAB(37);NS
  121. 2200 PRINT " Tracks per side:";TAB(37);TD
  122. 2210 PRINT " Number of File Allocation Tables:";TAB(37);B(17)
  123. 2220 PRINT " Sectors per File Allocation Table:";TAB(37);SF
  124. 2230 PRINT " Total sectors used by FATs:";TAB(37);TF
  125. 2240 PRINT " Maximum root directory entries:";TAB(37);RD
  126. 2250 PRINT " Sectors used by root directory:";TAB(37);SD
  127. 2260 PRINT " Sectors not used (unallocated):";TAB(37);US
  128. 2270 PRINT " Total number of clusters:";TAB(37);INT(SS/SC)
  129. 2280 PRINT " Total bytes available on disk:";TAB(37);TB#;"──";TB#/1024;CHR$(29);"K"
  130. 2290 PRINT " Total bytes available for data:";TAB(37);DS#;"──";DS#/1024;CHR$(29);"K"
  131. 2300 PRINT " Media descriptor byte [";HEX$(B(22));"]:";TAB(38);
  132. 2310 '
  133. 2320 ' media descriptor bytes defined by DOS:
  134. 2330 ' --------------------------------------
  135. 2340 '   F8 -- Fixed Disk or RAM disk
  136. 2350 '
  137. 2360 '   EF -- 3½ inch, 2 sides, 80 tracks, 36 sectors per track -- 2.88M
  138. 2370 '   F0 -- 3½ inch, 2 sides, 80 tracks, 18 sectors per track -- 1.44M
  139. 2380 '   F9 -- 3½ inch, 2 sides, 80 tracks,  9 sectors per track -- 720K
  140. 2390 '
  141. 2400 '   F9 -- 5¼ inch, 2 sides, 80 tracks, 15 sectors per track -- 1.2M
  142. 2410 '   FC -- 5¼ inch, 1 side,  40 tracks,  9 sectors per track -- 180K
  143. 2420 '   FD -- 5¼ inch, 2 sides, 40 tracks,  9 sectors per track -- 360K
  144. 2430 '   FE -- 5¼ inch, 1 side,  40 tracks,  8 sectors per track -- 160K
  145. 2440 '   FF -- 5¼ inch, 2 sides, 40 tracks,  8 sectors per track -- 320K
  146. 2450 '
  147. 2460 IF B(22)=248 THEN PRINT "Fixed Disk or RAM disk":GOTO 2550
  148. 2470 IF B(22)<>249 GOTO 2500
  149. 2480   IF ST=15 THEN PRINT F$;NS;S2$;:GOTO 2540
  150. 2490   IF ST=9  THEN PRINT T$;NS;S2$;:GOTO 2540
  151. 2500 IF B(22)=240 OR B(22)=239 THEN PRINT T$;NS;S2$;:GOTO 2540
  152. 2510 IF B(22)=252 OR B(22)=254 THEN PRINT F$;NS;S1$;:GOTO 2540
  153. 2520 IF B(22)=253 OR B(22)=255 THEN PRINT F$;NS;S2$;:GOTO 2540
  154. 2530 PRINT "(Unknown Disk Descriptor Byte)":GOTO 2550
  155. 2540 PRINT TD;S3$;ST;S$
  156. 2550 KILL "BOOTREC.SCR"
  157. 2560 KILL "BOOTREC.DAT"
  158. 2570 GOTO 1420 :' loop and prompt for another drive
  159. 2580 '
  160. 2590 ' --- Restore screen and exit to DOS ---
  161. 2600 '
  162. 2610 COLOR 7,0,0:CLS
  163. 2620 SYSTEM
  164.